package com.aurora.oa.home.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import com.aurora.oa.Constants.AuroraConstants;
import com.aurora.oa.R;
import com.aurora.oa.activity.BaseActivity;
import com.aurora.oa.home.bean.ArticleBean;
import com.aurora.oa.listener.OnRequestArticalDetailListener;
import com.aurora.oa.listener.OnRequestHttpDataListener;
import com.aurora.oa.model.RequestHttpModel;
import com.aurora.oa.model.RequestHttpModelImpl;
import com.aurora.oa.utils.ToastUtil;
import com.facebook.drawee.view.SimpleDraweeView;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/3/20 0020.
 */
public class ArticalDetailActivity extends BaseActivity{

    private ArticleBean articalData;
    @Bind(R.id.vebView)
    WebView vebView;
    String id;
    String url;
    RequestHttpModel model = new RequestHttpModelImpl();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setMyContentView(R.layout.activity_webview);
        ButterKnife.bind(this);
        initTitlebar(true, "资讯详情", true);
        getData();
        //   ;
    }

    private void getData() {
        Intent intent = getIntent();
        articalData = (ArticleBean) intent.getSerializableExtra("articalData");
        id = articalData.getId();
        model.getArticalDetail(id, new OnRequestArticalDetailListener() {
            @Override
            public void onRequestArticalDetailSuccess(String content) {
                WebSettings webSettings = vebView.getSettings();
                webSettings.setJavaScriptEnabled(true);
                vebView.setWebViewClient(new WebViewClient());
                vebView.loadDataWithBaseURL(null, content, "text/html", "utf-8", null);
            }

            @Override
            public void onRequestArticalDetailFail(String message) {
                ToastUtil.show(getApplicationContext(),message);
            }
        });
    }
}





